package com.qian.service.ddj.dao;

import com.qian.service.ddj.entity.DdjAliCode;
import com.yaowk.service.common.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

@Repository
public interface AliCodeRepository extends BaseRepository<DdjAliCode, Long> {
    DdjAliCode findFirstByBusinessIdAndAmountAndStatusOrderByVersion(Integer businessId, BigDecimal amount, Byte normal);

    @Modifying
    @Query(value = "update ddj_ali_code  set status = 1 where date_add(use_time,interval 5 minute) < now() and status = 3", nativeQuery = true)
    void clear();
}
